#!/bin/sh

app_name="japan"

app_dir="/opt/funfo/${app_name}"

branch=$1

if [[ -z "$branch" ]]; then
        branch="test"
elif [[ $1 == "1" ]]; then
        # 预设几个常用分支，不用每次都输入
        branch="feature-liufq"
fi

echo "------------ 开始部署 ${branch} 分支 ------------"

/home/tomcat/bin/shutdown.sh

cd $app_dir
git pull
git checkout $branch
git pull

mvn clean install
/bin/cp -rf ${app_dir}/web/target/${app_name}.war /home/tomcat/webapps/

echo "------------ 部署完成，重启 tomcat ... ------------"

/home/tomcat/bin/startup.sh

echo "------------ 重启完成 ------------"